package com.hui.qiniucloud.service;

import reactor.core.publisher.Flux;

/**
 * TTS V3服务接口
 * 
 * @author huihui
 * @since 2025-09-28
 */
public interface ITtsV3Service {

    /**
     * TTS请求参数类
     */
    class TtsRequest {
        private String text;
        private String speaker;
        private String format = "mp3";
        private Integer sampleRate = 24000;
        private Integer bitRate = 64000;
        private Integer loudnessRate = 0;
        private Integer speed = 0;
        private MixSpeaker mixSpeaker;
        
        // getters and setters
        public String getText() { return text; }
        public void setText(String text) { this.text = text; }
        public String getSpeaker() { return speaker; }
        public void setSpeaker(String speaker) { this.speaker = speaker; }
        public String getFormat() { return format; }
        public void setFormat(String format) { this.format = format; }
        public Integer getSampleRate() { return sampleRate; }
        public void setSampleRate(Integer sampleRate) { this.sampleRate = sampleRate; }
        public Integer getBitRate() { return bitRate; }
        public void setBitRate(Integer bitRate) { this.bitRate = bitRate; }
        public Integer getLoudnessRate() { return loudnessRate; }
        public void setLoudnessRate(Integer loudnessRate) { this.loudnessRate = loudnessRate; }
        public Integer getSpeed() { return speed; }
        public void setSpeed(Integer speed) { this.speed = speed; }
        public MixSpeaker getMixSpeaker() { return mixSpeaker; }
        public void setMixSpeaker(MixSpeaker mixSpeaker) { this.mixSpeaker = mixSpeaker; }
    }

    /**
     * 混音参数类
     */
    class MixSpeaker {
        private java.util.List<SpeakerMix> speakers;
        
        public java.util.List<SpeakerMix> getSpeakers() { return speakers; }
        public void setSpeakers(java.util.List<SpeakerMix> speakers) { this.speakers = speakers; }
    }

    /**
     * 单个混音音色类
     */
    class SpeakerMix {
        private String sourceSpeaker;
        private Double mixFactor;
        
        public String getSourceSpeaker() { return sourceSpeaker; }
        public void setSourceSpeaker(String sourceSpeaker) { this.sourceSpeaker = sourceSpeaker; }
        public Double getMixFactor() { return mixFactor; }
        public void setMixFactor(Double mixFactor) { this.mixFactor = mixFactor; }
    }

    /**
     * TTS响应结果类
     */
    class TtsResponse {
        private byte[] audioData;
        private String text;
        private int event;
        private boolean isFinished;
        
        public TtsResponse(byte[] audioData, String text, int event, boolean isFinished) {
            this.audioData = audioData;
            this.text = text;
            this.event = event;
            this.isFinished = isFinished;
        }
        
        // getters
        public byte[] getAudioData() { return audioData; }
        public String getText() { return text; }
        public int getEvent() { return event; }
        public boolean isFinished() { return isFinished; }
    }

    /**
     * WebSocket流式文字转语音 - V3双向流式API
     * @param request TTS请求参数
     * @return 音频数据流
     */
    Flux<TtsResponse> synthesizeSpeech(TtsRequest request);
}